<html>
<head>
<TITLE>CSE5317/4305 Project</TITLE>
</head>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<center>
<H1>CSE5317/4305 Project</H1>
</center>
<p>
<hr>
<p>
<dl>
<dt><b>Description</b><dd>
<p>
The project will be done in groups of three students.
It is your responsibility to find two other students and organize a project team. 
The course project is to construct a compiler for a small programming language,
called PCAT.
It will involve: lexical analysis, parsing, semantic analysis
(type-checking), and code generation
for a MIPS architecture. The project is to be
completed in seven stages spaced throughout the term.
<p>
<dt><b>Survival Tips</b><dd>
<p>
Select your teammates <i>very</i> carefully. Your project grade will
depend on them. Choose teammates whose abilities complement
yours. For example, you may be good in Java and this person may be good in
computer architecture and assembly programming. That way your group will
be strong in all aspects of this project. It's up to you to decide how
to divide the project work among your teammates. It's highly
unprofessional to come to me and complain about your teammates.
You should meet, solve your differences, and divide the work as
a professional team. Your project grade will not depend on
your abilities alone, but on how well your team achieves all the above tasks.
<p>
Start working on programming assignments as soon as they are handed
out. Do not wait till the day before the deadline. You will see that
assignments take much more time when you work on them under pressure
than when you are more relaxed. Remember that there is a severe
penalty for late submissions. Design carefully before you code. 
Writing a well-designed piece of code is always easier than starting
with some code that "almost works" and adding patches to
make it "really work".
<p>
Please read the following web page:
<a href="http://www.cs.cornell.edu/courses/cs412/2001sp/advice/group-notes.html">Developing Software in Groups</a>
by Andrew Myers, and <a href="http://www.cs.cornell.edu/courses/cs412/2003sp/advices.html">What to Avoid</a>, by Radu Rugina, for more tips.
<p>
<dt><b>Domain</b><dd>
<p>
A major part of this project is to implement a full compiler for
a subset of Pascal, called PCAT, designed by Andrew Tolmach at Portland State University.
The paper that describes the language can be retrieved from
<a href="pcat04.pdf">http://lambda.uta.edu/cse5317/pcat04.pdf</a>.
<p>
<dt><b>Platform and Tools</b><dd>
<p>
You can do your project either on your own PC or on omega at UTA.
In either case, you have to use JDK 6.
<p>
If you do the project on omega,
make sure that when you run '<tt>java -version</tt>' on omega, you get <tt>1.6.0_03</tt>.
If not, you need to add <tt>/opt/jdk1.6.0_03/bin</tt> to your PATH as follows:
edit the <tt>.login</tt> file in your top directory (note: the file name begins with a dot) and add
at the end of the file the line:
<pre>
setenv PATH /opt/jdk1.6.0_03/bin/:${PATH}
</pre>
Then logout and login again. Now <tt>java -version</tt> should say: java version "1.6.0_03"
<p>
To install the project on your own Linux PC or a Windows PC, you do:
<ul>
<li> If you do not have Java on your PC, install Sun's J2SE JDK 6 from
<a href="http://java.sun.com/j2se/downloads.html">http://java.sun.com/j2se/downloads.html</a>.
<li> Download the System jar archive that contains the CUP, JLex, and Gen classes from
<a href="http://lambda.uta.edu/System.jar">System.jar</a>
<li> Download the solution jar file
<a href="http://lambda.uta.edu/cse5317/Solution.jar">Solution.jar</a>
so you can compare the output of your program with that of the solution.
This jar file has been highly obfuscated and encrypted, so it's extremely difficult to decompile.
<li> Download the project source files:
<a href="http://lambda.uta.edu/cse5317/pcat.tar">pcat.tar</a> or
<a href="http://lambda.uta.edu/cse5317/pcat.zip">pcat.zip</a>.
These files contain minimal code.
Your goal for this project is to add more code in these files to make it function according to the specs.
</ul>
<p>
You can learn more about Java from:
<a href="http://lambda.uta.edu/cse6331/spring03/papers/TIJ/TIJ3.htm">Thinking in Java</a> (by Bruce Eckel),
<A HREF="http://java.sun.com/docs/books/tutorial/">Java Tutorial</a>,
<a href="http://java.sun.com/javase/6/docs/api/">API Specification</a>.
<p>
To make coding easier in Java, you will use the Gen package used in the
<a href="notes/node10.html">calculator example</a>
to build abstract syntax trees and intermediate representation trees. You will also
use a MIPS code simulator, called SPIM,
to run the assembly code generated by your compiler.
<p>
<dt><b>Program Grading</b><dd>
<p>
Programs will be graded according to their correctness, style, and
readability. Programs should behave as specified in the assignment
handouts. Bad data should be handled gracefully; your program should
never have run-time errors like dereferencing a null pointer or using
an out-of-bounds index. Special cases should be handled correctly.
Unnecessarily inefficient algorithms or constructs should be avoided;
however, efficiency should never be pursued at the expense of clarity
or simplicity.  Programs should be well documented, modular, and
flexible, i.e. easy to modify.  Indentation should reflect program
structure.  Use meaningful identifiers.  Avoid global variables and
side effects as much as possible. You should never use side effects
during the semantic actions of a parser.
The grader should be able to understand the program
without undue strain.  I will provide some test programs, but
these programs will not test your compiler exhaustively. It is your
responsibility to test every statement in your program by some piece
of test data.  Thorough testing is essential to establish the
reliability of your code.  Don't even think about adding fancy
features until the required work is completely debugged. A correctly
working simple program is worth much more (both in this class and in
actual practice) than a fancy program with bugs.
<p>
<dt><b>Cheating</b><dd>
<p>
You are allowed to collaborate with students of your project group only.
<b>No copying is permitted.</b> Cheating involves giving assistance
to or receiving assistance from members of other groups,
copying code from the web, etc.
You are required to use the Gen package (using the Meta class interface
for tree construction and pattern matching). It will be taken as cheating if you
use your own data structures or interface (since this would mean that
you have copied the code from elsewhere).
The punishment for cheating is a zero in the assignment and will be subject to
the university's academic dishonesty policy.
If you have any questions regarding an assignment, 
see the instructor or teaching assistant.
<p>
<dt><b>Deliverables</b><dd>
<p>
The projects and their due days are listed below.
The due time of each project is the midnight of the indicated due day.
You will hand-in your project source code electronically.
You may hand-in your source files as many times as you want;
only the last one will be taken into account.
Details of what do you need to hand-in (and how) can be found by clicking
on the appropriate project name.
Projects will be marked 20%-off per day.
So, there is no point submitting a project
more than 4 days late! No further extensions will be allowed. No excuses, no exceptions.
<p>
If you mess up a project phase, you can still do the next project phases
by removing the appropriate file name from your pcat directory. That way, the missing classes will be copied
from the Solution jar, rather than compiled from your source file.
For example, if you messed up Project #4, then in Project #5 you can remove
the file <tt>pcat/TypeCheck.gen</tt>, which will force the java compiler to
get the typecheck classes from Solution.jar.
Note that you can always go back and update your old projects, which is preferable from
using the solution, because you will have a better control over your own programs.
You can run the solution PCAT compiler over a test PCAT file,
say <tt>tests/tsort.pcat</tt>, using the command:
<pre>
solution 7 tsort
</pre>
inside your project directory. This runs project #7 over <tt>tests/tsort.pcat</tt> using the solution jar.
The goal of this project is to build a compiler for PCAT
that behaves the same as the solution PCAT compiler.
<p>
<dt><b>Project Phases</b><dd>
<p>
<ol>
<li> <a href="project1.html">Project #1</a> (lexical analysis):
Due M 2/4, worth 6% of your project grade.
You will implement the PCAT scanner using the JLex scanner generator.
Study the <a href="http://www.cs.princeton.edu/~appel/modern/java/JLex/current/manual.html">JLex manual</a>.<p>
<li> <a href="project2.html">Project #2</a> (parsing):
Due M 3/3, worth 14% of your project grade.
You will use the CUP parser generator to implement the PCAT parser.
Study the <a href="http://www.cs.princeton.edu/~appel/modern/java/CUP/manual.html">CUP manual</a>.<p>
<li> <a href="project3.html">Project #3</a> (abstract syntax):
Due W 3/12, worth 14% of your project grade.
You will define an abstract syntax tree (AST) type for PCAT and
you will add semantic actions to the PCAT parser to generate ASTs.<p>
<li> <a href="project4.html">Project #4</a> (type-checking):
Due M 3/31, worth 18% of your project grade.
You will implement the symbol tables and the type checking program for PCAT.<p>
<li> <a href="project5.html">Project #5</a> (simple IRs):
Due M 4/7, worth 18% of your project grade.
You will add  code to your parser to generate intermediate code (IR trees) for a subset of your ASTs.<p>
<li> <a href="project6.html">Project #6</a> (rest of IRs):
Due W 4/16, worth 16% of your project grade.
You will extend your parser to generate IRs for the rest of your ASTs.<p>
<li> <a href="project7.html">Project #7</a> (instruction selection):
Due W 4/30, worth 14% of your project grade.
This is the final stage in which you are asked to make your PCAT compiler generate MIPS code
and run it using SPIM.
</ol>

</dl>
<p>
<hr>
<P>
<ADDRESS>Last modified: 03/06/08 by <A HREF="http://lambda.uta.edu/">Leonidas Fegaras</A></ADDRESS>
